//    Copyright (C) Kherty.  All rights reserved.
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet
{
    class ExternalSheetData: IOfficeXmlSerializable
    {
        #region IOfficeXmlSerializable Members

        public void ReadXml(ReadContext context)
        {
            using (ReadContext c = context.Read("sheetData"))
            {
                SheetId = c.GetInteger("sheetId");
                while (c.ReaderLocalName == "row")
                    Rows.Add(c.ReadElement<ExternalRow>());
            }
        }

        public void WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("sheetData"))
            {
                c.SetInteger("sheetId", SheetId);
                foreach (ExternalRow row in Rows)
                    c.WriteElement(row);
            }
        }

        #endregion

        private List<ExternalRow> _rows = new List<ExternalRow>();

        public List<ExternalRow> Rows
        {
            get { return _rows; }
        }
	

        private int _sheetId;

        public int SheetId
        {
            get { return _sheetId; }
            set { _sheetId = value; }
        }
	
    }
}
